<?php
namespace Modules\Product\Http\Controllers\Admin\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use Modules\Product\Entities\Product;
use Modules\Product\Entities\ProductExt;

use Validator;
use ThrowException;
use DB;

class BatchEditController extends Controller
{
    public function totalStat(Request $req)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();

        $options = $req->all();

        $total = Product::getBuilder($options)->count();

        return [
            'total' => $total
        ];
    }

    public function store(Request $req)
    {
        $rule = [
        ];
        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();

        $options = $req->all();

        $builder = Product::getBuilder($options);

        if ($req->type === 'update_search_key') {
            $builder->update([
                'search_key' => $req->search_key
            ]);
        }
        
        return [
        ];
    }
}
